/* ===============================
| JQUERY.REGEXP.JS
| Copyright, Andy Croxall (mitya@mitya.co.uk)
| For documentation and demo see http://mitya.co.uk/scripts/Match-elements-via-REGEXP-jQuery-119
|
| USAGE
| This script may be used, distributed and modified freely but this header must remain in tact.
| For usage info and demo, including info on args and params, see www.mitya.co.uk/scripts
=============================== */


$(function() {
	jQuery.extend(jQuery.expr[':'], {
		regexp: function(node, index, selector) {
			return eval(selector[selector.length-1]).test(node.textContent||node.innerText||a([node])||"");
		}
	});
	jQuery.fn.regexp = function(pattern) {
		if (!pattern || !(pattern instanceof RegExp)) return false;
		var text = this.get(0).tagName.toLowerCase() != 'input' ? this.text() : this.val();
		return pattern.test(text) ? this : $('dummy');
	};
	jQuery.expr[':'].regex = function(elem, index, match) {
	    var matchParams = match[3].split(','),
	        validLabels = /^(data|css):/,
	        attr = {
	            method: matchParams[0].match(validLabels) ? 
	                        matchParams[0].split(':')[0] : 'attr',
	            property: matchParams.shift().replace(validLabels,'')
	        },
	        regexFlags = 'ig',
	        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
	    return regex.test(jQuery(elem)[attr.method](attr.property));
	};
});